<template>
  <div class="zs-table-page-container">
    <SearchTabTime :tag="`${tag} 更新`"></SearchTabTime>
    <div class="zs-card zs-table-page-content" v-loading="loading">
      <JointVentureTable :tableData="tableData" :updateDate="updateDate" :tabPermi="resourceKey">
      </JointVentureTable>
    </div>
  </div>
</template>
<script setup>
import SearchTabTime from '@/DbComponents/searchTabTime'
import JointVentureTable from '@/views/JointVenture/projectTable.vue'
import dbPublicApi from '@/api/dbPublic'
import { ref } from 'vue'

const resourceKey = 'p_btn_901_lianyingxiangmu_lianying'

let tag = ref('')
const loading = ref(false)
const tableData = ref([])
const updateDate = ref('')
const getDate = async () => {
  await dbPublicApi.queryDataTimeApi().then((res) => {
    if (res.data.code == 200) {
      tag.value = res.data.message
      updateDate.value = res.data.data
    }
  })
}
const getList = () => {
  loading.value = true
  tableData.value = []
  dbPublicApi.queryProjectPcApi({ dataTime: updateDate.value, resourceKey: resourceKey }).then((res) => {
    if (res.data.code == 200) {
      tableData.value = res.data.data
      loading.value = false
    }
  })
}
const getTabIndex = async () => {
  let list = await JSON.parse(localStorage.getItem('portalResourceList'))
  if (!list) { return false }
  return list.indexOf(resourceKey) > -1
}
const init = async () => {
  if (await getTabIndex()) {
    await getDate()
    getList()
  }
}
init()


</script>


<style scoped lang="scss"></style>
